package lab03.test03;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;

public class Test03 {

    public static void main(String[] args) {

        String path = "D:\\hello.txt";

        FileInputStream fileInputStream = null;
        FileOutputStream fileOutputStream = null;
        FileWriter fileWriter = null;

        try {
            fileOutputStream = new FileOutputStream(path);
            fileInputStream = new FileInputStream(path);

            fileOutputStream.write(new String("Hello World").getBytes());
            fileOutputStream.close();

            int data = 0;
            while ((data = fileInputStream.read()) != -1) {
                System.out.println((char) data);
            }
            fileInputStream.close();

            fileWriter = new FileWriter("D:\\hello.txt");
            fileWriter.write("Hello");
            fileWriter.close();


        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
